//
//  SSFocus.m
//  textDemo
//
//  Created by Esther on 2017/2/20.
//  Copyright © 2017年 Esther. All rights reserved.
//

#import "SSFocus.h"
#import "SSNetworkTools.h"
#import <AFNetworking.h>
#import "SSProgressHUD.h"

@interface SSFocus()
@property(nonatomic, strong) AFHTTPSessionManager *mgr;

@end

@implementation SSFocus{
//    AFHTTPSessionManager *_mgr;
    
}


#pragma mark -
#pragma mark - 发送POST请求

+ (void)loadFocusData:(void (^)(NSArray<SSFocus *> *data))completeBlock{
    
    [SSProgressHUD ss_show];
    NSDictionary *parameters = @{@"call":@1};
    [[SSNetworkTools shared] ss_postFocusData:@"loveBeen/focus.json.php" parameters:parameters completeBlock:^(id responseObject, NSError *error) {
               NSArray *arr = responseObject[@"data"][@"activities"];
               NSMutableArray *arrM = [NSMutableArray array];
               for (NSDictionary *dict in arr) {
                   SSFocus *focusData = [SSFocus yy_modelWithDictionary:dict];
                   [arrM addObject:focusData];
                   
               }
        if (completeBlock) {
               completeBlock(arrM.copy);

           }
        
    }];
    
//    [s]
//    
//    [self.mgr POST:@"loveBeen/focus.json.php"
//    parameters:parameters
//      progress:nil
//       success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//           //成功
//           [SSProgressHUD ss_dismiss];
//           NSArray *arr = responseObject[@"data"][@"activities"];
//           NSMutableArray *arrM = [NSMutableArray array];
//           for (NSDictionary *dict in arr) {
//               SSFocus *focusData = [SSFocus yy_modelWithDictionary:dict];
//               [arrM addObject:focusData];
//               
//           }
//           
//           if (completeBlock) {
//               completeBlock(arrM.copy,nil);
//               
//           }
//        
//       }
//       failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//           [SSProgressHUD ss_dismiss];
//           // 失败
//           if (completeBlock) {
//               NSLog(@"%@",error);
//               completeBlock(nil,error);
//               
//           }
//       }];
    
}


@end
